using System;
using System.Collections.Generic;

using UnityEngine;

/// <summary>
/// Stores a set of stats 
/// </summary>
public class StatSet
{
	//Dictionary storing a set of stats and their corresponding values
	private Dictionary<string, float> mStatDict;

	public StatSet ()
	{
		mStatDict = new Dictionary<string, float>();
	}

	/// <summary>
	/// Gets the number of different stats in the dictionary
	/// </summary>
	/// <value>The number of different stats in the dictionary</value>
	public int NumStats{
		get{
			return mStatDict.Count;
		}
	}

	/// <summary>
	/// Gets the value for a particular stat
	/// </summary>
	/// <returns>The value for stat if it exists, otherwise 0</returns>
	/// <param name="statName">Name of the stat to get the value for</param>
	public float GetValueForStat(string statName){
		float statVal;
		if(mStatDict.TryGetValue(statName, out statVal)){
			return statVal;
		}else{
			Debug.LogWarning("Attempted to get value for stat '" + statName + "' which has not been set!");
			return 0;
		}
	}

	/// <summary>
	/// Sets the value for a particular stat
	/// </summary>
	/// <param name="statName">Name of the stat to set the value for</param>
	/// <param name="value">Value to set for the stat</param>
	public void SetValueForStat(string statName, float value){
		mStatDict[statName] = value;
	}

	/// <summary>
	/// Gets a list of all the stat names in this set
	/// </summary>
	/// <returns>A list of all the stat names in this set</returns>
	public List<string> GetAllStatNames(){
		List<string> allNames = new List<string>();
		foreach(string statName in mStatDict.Keys){
			allNames.Add(statName);
		}

		return allNames;
	}
}


